matrix=[
[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]
]
target = int(input("请输入要查找的值:"))
m = len(matrix)
n = len(matrix[0])
# 初始位置在左下角
x = m - 1
y = 0
while 0 <= x < m and 0 <= y < n:
    # 找到直接返回True
    if matrix[x][y] == target:
         print('True')
    # target更大，向右
    elif matrix[x][y] < target:
        y += 1
    # target更小，向左
    else:
        x -= 1
# 没找到，返回False
print('False')
